//
// Created by sjjmw on 3/24/2022.
//
#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
void handle(int cnt,std::unordered_map<int,char>& zhongjiang
            ){
    std::vector<int> prize_cnt(7);
    for(int i=0;i<cnt;i++){
        //一张彩票
        int cnt=0;
        for(int j=0;j<7;j++){
            int in;std::cin>>in;
            if(zhongjiang.find(in)!=zhongjiang.end()){
                cnt++;
            }
        }
        if(cnt>0){
            prize_cnt[cnt-1]++;
        }
    }
    for(int i=prize_cnt.size()-1;i>=0;i--){
        printf("%d ",prize_cnt[i]);
    }
    printf("\n");
}

int main(){
    int a,b,c;
    std::unordered_map<int,char> zhongjiang;
//std::vector<int> buf(7);
    while(
            std::cin>>a
    ){
        for(int i=0;i<7;i++){
            int in;
            std::cin>>in;
            zhongjiang[in]=1;
        }
        handle(a,zhongjiang);
    }
    return 0;
}